package com.example.gzysmartcity.ui.adapter;

import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.gzysmartcity.R;
import com.example.gzysmartcity.repository.model.Opinion;
import com.example.gzysmartcity.utils.BitmapUntil;

import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class HistoryAdapter extends BaseQuickAdapter<Opinion, BaseViewHolder> {
    public HistoryAdapter(int layoutResId) {
        super(layoutResId);
        simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA);
    }

    private final SimpleDateFormat simpleDateFormat;


    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, Opinion news) {
        ImageView imageView = baseViewHolder.getView(R.id.imgRvItemNews);
        List<String> images = news.getStringList();

        if (images != null && images.size() > 0) {
            Glide.with(getContext()).load(images.get(0)).placeholder(R.drawable.error).into(imageView);
        }
        baseViewHolder.setText(R.id.tvRvItemNewsTitle, "联系方式：" + news.getPhone());
        baseViewHolder.setText(R.id.tvRvItemNewsContent, news.getContent());
        baseViewHolder.setText(R.id.tvRvItemNewsDate, simpleDateFormat.format(new Date(news.getDate())));
    }
}
